package com.racer.iterator;
import java.util.Iterator;
import java.util.Calendar;
import com.racer.iterator.MenuItem;

public class AlternatingDinerMenuIterator implements Iterator{
	MenuItem[] items;
	int position;
	public AlternatingDinerMenuIterator(MenuItem[] items){
		this.items=items;
		Calendar rightnow = Calendar.getInstance();
		position = rightnow.get(Calendar.DAY_OF_WEEK)%2;
	}

	public Object next(){
		MenuItem menuItem= items[position];
		position+=2;
		return menuItem;
	}

	public boolean hasNext(){
		if(position>=items.length||items[position]==null){
			return false;
		}
		else{
			return true;
		}
	}

	public void remove(){
		throw new UnsupportedOperationException("Alternating Diner Menu Iterator does not support remove");
	}
}
